<cfinclude template="components/settings.cfm">
<cfset hash = #URL.confirm#>

<cfquery name="checkForActivation" datasource="#fSDS#">

	SELECT * FROM commenters
	WHERE `randomHash` = '#hash#'

</cfquery>

<cfoutput query="checkForActivation">

	<cfset whatDidIFind = IsDefined('randomHash')>
    
    <cfif IsDefined('commenterID')>
    	<cfset andMyNameIs = #commenterID#>
    </cfif>

</cfoutput><title>Activating Your Email: <cfoutput>#fSSN#</cfoutput></title>

	<cfif whatDidIFind is "YES">
	
		<cfquery name="activateCommenter" datasource="#fSDS#">
			
            UPDATE commenters
			SET `approved` = '1'
			WHERE `randomHash` = '#hash#'
		
        </cfquery>
        
        <cfquery name="activateComments" datasource="#fSDS#">
        	UPDATE comments
            SET `commentActivated` = '1'
            WHERE `commenterLinkID` = '#andMyNameIs#'
        </cfquery>

		<cfoutput>Thanks very much - your email address has been successfully activated and all submitted comments have been approved.</cfoutput>

	<cfelse>
	
		<cfoutput>Hmm... are you sure that URL is correct? I was unable to find a record for that email address. No addresses were activated nor were any comments approved.</cfoutput>
	
	</cfif>
	<cfinclude template="components/footer.cfm">